package br.mercadofacil.app.hma;




import com.google.ads.AdRequest;
import com.google.ads.AdView;


import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageButton;

public class Lista_Enlatados extends Activity {

	String Aspargos = "";
	String Atum = "";
	String Azeitona = "";
	String Cogumelo = "";
	String CremedeLeite = "";
	String DocedeLeite = "";
	String LeiteCondensado = "";
	String Ervilha = "";
	String MilhoVerde = "";
	String MolhodeTomate = "";
	String Palmito = "";
	String Sardinha = "";

	CheckBox chbAspargos, chbAtum, chbAzeitona, chbCogumelo, chbCremedeLeite,
			chbDocedeleite, chbLeiteCondensado, chbErvilha, chbMilhoVerde,
			chbMolhodeTomate, chbPalmito, chbsardinha;

	public static final String PREFS_NAME = "SharedPrefsDemoPreferences";
	private SharedPreferences mPrefs;
	
	private CheckBox CheckBoxAspargos, CheckBoxAtum, CheckBoxAzeitona,
			CheckBoxCogumelo, CheckBoxCremedeLeite, CheckBoxDocedeLeite,
			CheckBoxLeiteCondensado, CheckBoxErvilha, CheckBoxMilhoVerde,
			CheckBoxMolhodeTomate, CheckBoxPalmito, CheckBoxSardinha;
	public static final String PREF_BOOL1 = "PrefBool1";
	public static final String PREF_BOOL2 = "PrefBool2";
	public static final String PREF_BOOL3 = "PrefBool3";
	public static final String PREF_BOOL4 = "PrefBool4";
	public static final String PREF_BOOL5 = "PrefBool5";
	public static final String PREF_BOOL6 = "PrefBool6";
	public static final String PREF_BOOL7 = "PrefBool7";
	public static final String PREF_BOOL8 = "PrefBool8";
	public static final String PREF_BOOL9 = "PrefBool9";
	public static final String PREF_BOOL10 = "PrefBool10";
	public static final String PREF_BOOL11 = "PrefBool11";
	public static final String PREF_BOOL12 = "PrefBool12";

	ImageButton btnPagina2;

	public static Object LevaAspargo;
	public static Object LevaATum;
	public static Object LevaAzeitona;
	public static Object LevaCogumelo;
	public static Object LevaCremedeLeite;
	public static Object LevaDocedeLeite;
	public static Object LevaLeiteCondensado;
	public static Object LevaErvilha;
	public static Object LevaMilhoVerde;
	public static Object LevaMolhodeTamate;
	public static Object LevaPalimto;
	public static Object LevaSardinha;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.aba_enlatados);
		
		AdView adView = (AdView)this.findViewById(R.id.adView);  
		adView.loadAd(new AdRequest());  

		mPrefs = getSharedPreferences(PREFS_NAME, 0);

		CheckBoxAspargos = (CheckBox) findViewById(R.id.checkBoxAspargos);
		chbAspargos = (CheckBox) findViewById(R.id.checkBoxAspargos);
		CheckBoxAtum = (CheckBox) findViewById(R.id.checkBoxAtum);
		chbAtum = (CheckBox) findViewById(R.id.checkBoxAtum);
		CheckBoxAzeitona = (CheckBox) findViewById(R.id.checkBoxAzeitona);
		chbAzeitona = (CheckBox) findViewById(R.id.checkBoxAzeitona);
		CheckBoxCogumelo = (CheckBox) findViewById(R.id.checkBoxCogumelo);
		chbCogumelo = (CheckBox) findViewById(R.id.checkBoxCogumelo);
		CheckBoxCremedeLeite = (CheckBox) findViewById(R.id.checkBoxCremedeLeite);
		chbCremedeLeite = (CheckBox) findViewById(R.id.checkBoxCremedeLeite);
		CheckBoxDocedeLeite = (CheckBox) findViewById(R.id.checkBoxDocedeLeite);
		chbDocedeleite = (CheckBox) findViewById(R.id.checkBoxDocedeLeite);
		CheckBoxLeiteCondensado = (CheckBox) findViewById(R.id.checkBoxLeiteCondensado);
		chbLeiteCondensado = (CheckBox) findViewById(R.id.checkBoxLeiteCondensado);
		CheckBoxErvilha = (CheckBox) findViewById(R.id.checkBoxErvilha);
		chbErvilha = (CheckBox) findViewById(R.id.checkBoxErvilha);
		CheckBoxMilhoVerde = (CheckBox) findViewById(R.id.checkBoxMilhoVerde);
		chbMilhoVerde = (CheckBox) findViewById(R.id.checkBoxMilhoVerde);
		CheckBoxMolhodeTomate = (CheckBox) findViewById(R.id.checkBoxMolhodeTomate);
		chbMolhodeTomate = (CheckBox) findViewById(R.id.checkBoxMolhodeTomate);
		CheckBoxPalmito = (CheckBox) findViewById(R.id.checkBoxPalmito);
		chbPalmito = (CheckBox) findViewById(R.id.checkBoxPalmito);
		CheckBoxSardinha = (CheckBox) findViewById(R.id.checkBoxSardinha);
		chbsardinha = (CheckBox) findViewById(R.id.checkBoxSardinha);

		btnPagina2 = (ImageButton) findViewById(R.id.btnPagina2);

		btnPagina2.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				// TODO Auto-generated method stub

				if (chbAspargos.isChecked()) {
					Aspargos = "Aspargos";

				}
				if (chbAtum.isChecked()) {
					Atum = "Atum";

				}
				if (chbAzeitona.isChecked()) {
					Azeitona = "Azeitonas";

				}
				if (chbCogumelo.isChecked()) {
					Cogumelo = "Cogumelo";

				}
				if (chbCremedeLeite.isChecked()) {
					CremedeLeite = "Creme de Leite";

				}
				if (chbDocedeleite.isChecked()) {
					DocedeLeite = "Doce de Leite";

				}
				if (chbLeiteCondensado.isChecked()) {
					LeiteCondensado = "Leite Condensado";

				}
				if (chbErvilha.isChecked()) {
					Ervilha = "Ervilha";

				}
				if (chbMilhoVerde.isChecked()) {
					MilhoVerde = "Milho Verde";

				}
				if (chbMolhodeTomate.isChecked()) {
					MolhodeTomate = "Molho de Tomate";

				}
				if (chbPalmito.isChecked()) {
					Palmito = "Palmito";

				}
				if (chbsardinha.isChecked()) {
					Sardinha = "Sardinha";

				}

				LevaAspargo = Aspargos;
				LevaATum = Atum;
				LevaAzeitona = Azeitona;
				LevaCogumelo = Cogumelo;
				LevaCremedeLeite = CremedeLeite;
				LevaDocedeLeite = DocedeLeite;
				LevaLeiteCondensado = LeiteCondensado;
				LevaErvilha = Ervilha;
				LevaMilhoVerde = MilhoVerde;
				LevaMolhodeTamate = MolhodeTomate;
				LevaPalimto = Palmito;
				LevaSardinha = Sardinha;
				
				startActivity(new Intent(Lista_Enlatados.this, Lista_Feira.class));

			}
		});

	}

	@Override
	protected void onResume() {

		CheckBoxAspargos.setChecked(mPrefs.getBoolean(PREF_BOOL1, false));
		CheckBoxAtum.setChecked(mPrefs.getBoolean(PREF_BOOL2, false));
		CheckBoxAzeitona.setChecked(mPrefs.getBoolean(PREF_BOOL3, false));
		CheckBoxCogumelo.setChecked(mPrefs.getBoolean(PREF_BOOL4, false));
		CheckBoxCremedeLeite.setChecked(mPrefs.getBoolean(PREF_BOOL5, false));
		CheckBoxDocedeLeite.setChecked(mPrefs.getBoolean(PREF_BOOL6, false));
		CheckBoxLeiteCondensado
				.setChecked(mPrefs.getBoolean(PREF_BOOL7, false));
		CheckBoxErvilha.setChecked(mPrefs.getBoolean(PREF_BOOL8, false));
		CheckBoxMilhoVerde.setChecked(mPrefs.getBoolean(PREF_BOOL9, false));
		CheckBoxMolhodeTomate.setChecked(mPrefs.getBoolean(PREF_BOOL10, false));
		CheckBoxPalmito.setChecked(mPrefs.getBoolean(PREF_BOOL11, false));
		CheckBoxSardinha.setChecked(mPrefs.getBoolean(PREF_BOOL12, false));

		super.onResume();
	}

	@Override
	protected void onPause() {
		Editor e = mPrefs.edit();
		e.putBoolean(PREF_BOOL1, CheckBoxAspargos.isChecked());
		e.putBoolean(PREF_BOOL2, CheckBoxAtum.isChecked());
		e.putBoolean(PREF_BOOL3, CheckBoxAzeitona.isChecked());
		e.putBoolean(PREF_BOOL4, CheckBoxCogumelo.isChecked());
		e.putBoolean(PREF_BOOL5, CheckBoxCremedeLeite.isChecked());
		e.putBoolean(PREF_BOOL6, CheckBoxDocedeLeite.isChecked());
		e.putBoolean(PREF_BOOL7, CheckBoxLeiteCondensado.isChecked());
		e.putBoolean(PREF_BOOL8, CheckBoxErvilha.isChecked());
		e.putBoolean(PREF_BOOL9, CheckBoxMilhoVerde.isChecked());
		e.putBoolean(PREF_BOOL10, CheckBoxMolhodeTomate.isChecked());
		e.putBoolean(PREF_BOOL11, CheckBoxPalmito.isChecked());
		e.putBoolean(PREF_BOOL12, CheckBoxSardinha.isChecked());

		e.commit();
		super.onPause();
	}

}
